package io.zcoder.innoway.fragments;


import android.app.Fragment;
import android.support.annotation.Nullable;
import android.view.View;

import butterknife.BindView;
import io.zcoder.innoway.R;
import io.zcoder.innoway.activities.BaseActivity;
import io.zcoder.innoway.widgets.TextViewCustom;

public class BaseFragment extends Fragment {

    @Nullable
    @BindView(R.id.common_title)
    TextViewCustom mTitle;

    public void showAlert(String title, String message) {
        if (getActivity() instanceof BaseActivity) {
            BaseActivity activity = (BaseActivity) getActivity();
            activity.showAlert(title, message);
        }
    }

    public void showProgress() {
        if (getActivity() instanceof BaseActivity) {
            BaseActivity activity = (BaseActivity) getActivity();
            activity.showProgress();
        }
    }

    public synchronized void hideProgress() {
        if (getActivity() instanceof BaseActivity) {
            BaseActivity activity = (BaseActivity) getActivity();
            activity.hideProgress();
        }
    }

    public void setTitle(String title) {
        showTitle(true);
        if (mTitle != null) {
            mTitle.setText(title);
        }
    }

    public void showTitle(boolean show) {
        if (mTitle != null) {
            mTitle.setVisibility(show ? View.VISIBLE : View.GONE);
        }
    }
}
